<template>
  <!-- Contact Medical Consultant -->
  <div class="application">
    <div class="app_title">
      <img src="@/static/images/news/left_line.png"
           class="boundary" />
      <div class="app_title_font">Counselling Service</div>
      <img src="@/static/images/news/right_line.png"
           class="boundary" />
    </div>
    <div :class="leaveWord.lyType == '01' ? 'app_unit app_unit2' : 'app_unit'"
         @click="leaveWord.lyType = '01'">Global Drug Search</div>
    <div :class="leaveWord.lyType == '02' ? 'app_unit app_unit2' : 'app_unit'"
         @click="leaveWord.lyType = '02'">Clinical Research Recruitment</div>
    <div :class="leaveWord.lyType == '03' ? 'app_unit app_unit2' : 'app_unit'"
         @click="leaveWord.lyType = '03'">Overseas Medical Treatment</div>
    <div :class="leaveWord.lyType == '04' ? 'app_unit app_unit2' : 'app_unit'"
         @click="leaveWord.lyType = '04'">Remote Consultations</div>
    <input v-model="leaveWord.tel"
           class="app_unit_number"
           type="text"
           placeholder="Please enter your phone number." />
    <textarea v-model="leaveWord.content"
              class="app_unit_number"
              placeholder="Please enter your content." />
    <div class="tips">Note: Our medical consultant will contact you as soon as possible. We promise to strictly protect your privacy.</div>
    <div class="refer"
         @click="submit()">Submit</div>
  </div>
</template>

<script>
import { addLeaveWord } from '@/api/api'

export default {
  data () {
    return {
      modelName: '',
      leaveWord: {
        //留言板类型 默认全球找药
        lyType: null,
        //留言类型
        type: null,
        //姓名
        name: '',
        //留电方式 -- 邮箱
        tel: '',
        //备注  --WeChat
        content: ''

      }
    }
  },
  methods: {
    choosemodel (name) {
      this.modelName = name
    },
    submit () {
      if (this.leaveWord.tel == '') {
        this.$notify({
          title: 'tip',
          message: 'Please enter your contact information.',
        });
        return;
      } else if (this.leaveWord.content == '') {
        this.$notify({
          title: 'tip',
          message: 'Please enter the information you need to consult.',
        });
        return;
      }
      this.leaveWord.type = '02'

      this.$axios.post(addLeaveWord, this.leaveWord).then(res => {

        this.$notify({
          title: 'tip',
          message: res.msg,
        });

        this.leaveWord = {
          lyType: null,
          type: null,
          name: '',
          tel: '',
          content: ''
        }
      });
    },
  },
}
</script>

<style lang="scss" scoped>
.application {
  margin-top: 32px;
  overflow: hidden;
  .app_title {
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 6px;
    .boundary {
      width: 20px;
      height: 10px;
    }
    .app_title_font {
      font-weight: bold;
      font-size: 19px;
      color: #0041a3;
    }
  }
  .app_unit {
    border: 1px solid #0041a3;
    font-size: 18px;
    color: #0041a3;
    line-height: 48px;
    text-align: center;
    margin-top: 16px;
    cursor: pointer;
  }
  .app_unit2 {
    background: rgba(0, 120, 255, 0.1);
    border: 1px solid rgba(0, 120, 255, 0.1);
  }
  .app_unit_number {
    border: 1px solid #cbd1d7;
    font-size: 16px;
    color: #8a95a2;
    line-height: 48px;
    margin-top: 16px;
    width: 336px;
    max-width: 336px;
    padding-left: 16px;
    font-family: Arial, Arial;
    outline: none;
  }
  .tips {
    font-size: 12px;
    color: #0041a3;
    line-height: 19px;
    margin-top: 14px;
  }
  .refer {
    background: #0041a3;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    line-height: 50px;
    margin-top: 14px;
    cursor: pointer;
  }
}
</style>